let utils = data["utils"];
let STUtil = data["STUtil"];
let Node = data["Node"];
let SplayTree = data["SplayTree"];
let isInBbox = data["isInBbox"];
let getBboxOverlap = data["getBboxOverlap"];
let cmp = data["cmp"];
let crossProduct = data["crossProduct"];
let dotProduct = data["dotProduct"];
let compareVectorAngles = data["compareVectorAngles"];
let sineOfAngle = data["sineOfAngle"];
let cosineOfAngle = data["cosineOfAngle"];
let closestPoint = data["closestPoint"];
let horizontalIntersection = data["horizontalIntersection"];
let verticalIntersection = data["verticalIntersection"];
let intersection = data["intersection"];
let perpendicular = data["perpendicular"];
let rounder = data["rounder"];

console.log("09PolygonClipping_geom-in01");

let segmentId = 0
function Segment(leftSE, rightSE, rings, windings) {
  this.id = ++segmentId, this.leftSE = leftSE, leftSE.segment = this, leftSE.otherSE = rightSE, this.rightSE = rightSE, rightSE.segment = this, rightSE.otherSE = leftSE, this.rings = rings, this.windings = windings
}

function RingIn(geomRing, poly, isExterior) {
  this.getSweepEvents = function () {
    const sweepEvents = [];
    for (let i = 0, iMax = this.segments.length; i < iMax; i++) {
      const segment = this.segments[i];
      sweepEvents.push(segment.leftSE), sweepEvents.push(segment.rightSE)
    }
    return sweepEvents
  }, this.init = function (geomRing, poly, isExterior) {
    if (!Array.isArray(geomRing) || 0 === geomRing.length) throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
    if (this.poly = poly, this.isExterior = isExterior, this.segments = [], "number" != typeof geomRing[0][0] || "number" != typeof geomRing[0][1]) throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
    const firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
    this.bbox = {
      ll: {
        x: firstPoint.x,
        y: firstPoint.y
      },
      ur: {
        x: firstPoint.x,
        y: firstPoint.y
      }
    };
    let prevPoint = firstPoint;
    for (let i = 1, iMax = geomRing.length; i < iMax; i++) {
      if ("number" != typeof geomRing[i][0] || "number" != typeof geomRing[i][1]) throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
      let point = rounder.round(geomRing[i][0], geomRing[i][1]);
      point.x === prevPoint.x && point.y === prevPoint.y || (this.segments.push(Segment.fromRing(prevPoint, point, this)), point.x < this.bbox.ll.x && (this.bbox.ll.x = point.x), point.y < this.bbox.ll.y && (this.bbox.ll.y = point.y), point.x > this.bbox.ur.x && (this.bbox.ur.x = point.x), point.y > this.bbox.ur.y && (this.bbox.ur.y = point.y), prevPoint = point)
    }
    firstPoint.x === prevPoint.x && firstPoint.y === prevPoint.y || this.segments.push(Segment.fromRing(prevPoint, firstPoint, this))
  }, this.init(geomRing, poly, isExterior)
}

var geomIn = {
  RingIn: RingIn
};

return {
  "utils": utils,
  "STUtil": STUtil,
  "Node": Node,
  "SplayTree": SplayTree,
  "isInBbox": isInBbox,
  "getBboxOverlap": getBboxOverlap,
  "cmp": cmp,
  "crossProduct": crossProduct,
  "dotProduct": dotProduct,
  "compareVectorAngles": compareVectorAngles,
  // "length":length,
  "sineOfAngle": sineOfAngle,
  "cosineOfAngle": cosineOfAngle,
  "closestPoint": closestPoint,
  "horizontalIntersection": horizontalIntersection,
  "verticalIntersection": verticalIntersection,
  "intersection": intersection,
  "perpendicular": perpendicular,
  "rounder": rounder,
  "geomIn": geomIn,
  "Segment": Segment
}